using System.Collections.Generic;

public class Table_EffectItem : IDataItem
{
	/// <summary>
	/// 唯一ID
	/// <summary>
	public int Id { get; private set; }
	/// <summary>
	/// Prefab路径或ModelID
	/// <summary>
	public string Path { get; private set; }
	/// <summary>
	/// 特效延迟时间
	/// <summary>
	public int DelayTime { get; private set; }
	/// <summary>
	/// 是否播放完只失效(0销毁，1不销毁只失效）
	/// <summary>
	public bool IsOnlyDeactive { get; private set; }
	/// <summary>
	/// 位置
	/// <summary>
	public int GetPosCount() { return Pos.Count; }
	private List<int> Pos = new List<int>();
	public int GetPosByIndex(int idx)
	{
		return Pos.GetValueByIdx(idx, 0);
	}
	/// <summary>
	/// 旋转
	/// <summary>
	public int GetRotaCount() { return Rota.Count; }
	private List<int> Rota = new List<int>();
	public int GetRotaByIndex(int idx)
	{
		return Rota.GetValueByIdx(idx, 0);
	}
	/// <summary>
	/// 持续时间 0代表循环
	/// <summary>
	public int Duration { get; private set; }

	public Table_EffectItem(ExcelLineReader reader)
	{
		Id = reader.ReadInt();
		Path = reader.ReadString();
		DelayTime = reader.ReadInt();
		IsOnlyDeactive = reader.ReadBool();
		Pos = reader.ReadShortString().ToIntList();
		Rota = reader.ReadShortString().ToIntList();
		Duration = reader.ReadInt();
	}
}

public class Table_EffectMgr : IDataMgr
{
	protected override string FileName { get { return "Txt/Effect.txt"; } }

	protected Dictionary<int, int> mItemDic = new Dictionary<int, int>();
	public int GetIdxById(int key) { return mItemDic[key]; }

	public override void Load(ExcelLineReader reader)
	{
		var item = new Table_EffectItem(reader);
		mItemDic[item.Id] = DataCount;
		mItemList.Add(item);
	}

	public Table_EffectItem GetItemByIdx(int idx)
	{
		return GetItemByIdx<Table_EffectItem>(idx);
	}

	public Table_EffectItem GetItemById(int id)
	{
		int idx = GetIdxById(id);
		return GetItemByIdx(idx);
	}
}